﻿Public Class USUARIOS
    Public Function Crypt(ByVal Text As String) As String
        Dim strTempChar As String

        For i = 1 To Len(Text)

            If Asc(Mid$(Text, i, 1)) < 128 Then
                strTempChar = Asc(Mid$(Text, i, 1)) + 128
            ElseIf Asc(Mid$(Text, i, 1)) > 128 Then
                strTempChar = Asc(Mid$(Text, i, 1)) - 128
            End If

            Mid$(Text, i, 1) = Chr(strTempChar)

        Next i
        Crypt = Text
    End Function
    Private Sub USUARIOS_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.LoginTableAdapter.Fill(Me.LOGINDataSet.Login)
    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        LoginBindingSource.MoveFirst()
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        LoginBindingSource.MovePrevious()
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        LoginBindingSource.AddNew()
    End Sub

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
        Try
            SENHATextBox.Text = Crypt(SENHATextBox.Text)
            Me.Validate()
            Me.LoginBindingSource.EndEdit()
            TableAdapterManager.UpdateAll(LOGINDataSet)
        Catch EX As Exception
            MsgBox("ERRO AO SALVAR/ATUALIZAR CADASTRO " & EX.ToString)
        End Try
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        LoginBindingSource.MoveNext()
    End Sub

    Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
        LoginBindingSource.MoveLast()
    End Sub

    Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
        Try
            Me.Validate()
            LoginBindingSource.RemoveCurrent()
            LoginTableAdapter.Adapter.Update(LOGINDataSet.Login)
        Catch EX As Exception
            MsgBox("ERRO AO DELETAR O REGISTRO " & EX.ToString)
        End Try
    End Sub
End Class